#! /bin/bash
#
# li.sh
# Copyright (C) 2020 zimingzpp <zimingzpp@qq.com>
#
#2020.6.15
#
# Distributed under terms of the MIT license.
#

USER=root   #登录用户#
PASS=gchaktd2020 #登录密码#

#expect自动交互
for ip in `cat ip`
do
/usr/bin/expect << EOF
set timeout 5
spawn /usr/bin/ssh-copy-id  $USER@$ip
expect {
        "*yes/no*" { send "yes\r";exp_continue }
        "password:" { send "$PASS\n";exp_continue } 
        eof { exit }
        }
EOF

done

exit
